package com.tengroup.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tengroup.entity.StudentScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface StudentScoreDao extends BaseMapper<StudentScoreEntity> {
    @Select("SELECT AVG(student_score) as avgScore FROM student_score " +
            "WHERE paper_id = #{paperId} AND user_id = #{userId}")
    Double selectAverageScoreByPaperIdAndUserId(@Param("paperId") Long paperId, @Param("userId") Long userId);
    @Select("SELECT AVG(student_score) as avgScore FROM student_score " +
            "WHERE paper_id = #{paperId} AND class_id = #{classId} AND exam_time = #{examTime}")
    Double selectAverageScoreByPaperIdAndClassIdAndExamTime(
            @Param("paperId") Long paperId, @Param("classId") Long classId,
            @Param("examTime") LocalDateTime examTime);
}